import request from '../../utils/request.js'


// 用户名注册功能  /user/registerByUsername  post 
export const registerByUsername = (data) => request({
	url: '/user/registerByUsername',
	method: "post",
	data
})

// 用户名登陆功能  /user/login  post 
export const UserLogin = (data) => request({
	url: "/user/login",
	method: "post",
	data
})

// 获取当前用户信息  /user/current   GET
export const getUserInfo = () => request({
	url: '/user/current',
	method: 'get'
})

// 更新用户信息   /user/update   POST
export const updateUser = (data) => request({
	url: '/user/update',
	method: 'POST',
	data
})

// 获取收货地址 /address/list  get 
export const getAddress = () => request({
	url: '/address/list',
	method: "get"
})

//     /address/delete/{id}   删除收货信息 post
export const delAddress = (id) => request({
	url: `/address/delete/${id}`,
	method: "post"
})

// 修改默认地址    /address/updateDefault/{id}  post 
export const updateDefault = (id, state) => request({
	url: `/address/updateDefault/${id}?status=${state}`,
	method: "post",
})

// 获取省市区三级联动列表  /address/area   GET
export const getaddressArea = () => request({
	url: '/address/area',
	method: "get"
})


// 修改  /address/update/{id}  post 
export const updateAddress = (id, data) => request({
	url: `/address/update/${id}`,
	method: "post",
	data
})


// 新增收货信息   /address/add  POST 
export const addAddress=(data)=>request({
	url: `/address/add`,
	method: "post",
	data
})


//  获取当前商品相关优惠券 /portalCoupon/listByProduct/{productId}  get 
export const getlistByProduct=(productId)=>request({
	url:`/portalCoupon/listByProduct/${productId}`,
	method:'get'
})


// 领取优惠卷  /portalCoupon/add/{couponId}  post
export const GetDiscounts=(couponId)=>request({
	url:`/portalCoupon/add/${couponId}`,
	method:'post'
})

//  获取会员优惠券列表  /portalCoupon/list get
export const portalCouponList=()=>request({
	url:'/portalCoupon/list',
	method:'get',
	params:{
		useStatus:0
	}
})



//  获取订单分页列表  /portalOrder/page    GET  
export const portalOrder=(data)=>request({
	url:'/portalOrder/page',
	method:'GET',
	data
})
